<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" session="false" %>
<html>
<head>
    <title>注册</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">
    <link href="${pageContext.request.contextPath}/static/css/common.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/css/bootstrap.min.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/font-awesome-4.3.0/css/font-awesome.min.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/select2-4.0.0/dist/css/select2.min.css"
          rel="stylesheet">
    <!-- jqgrid-->
    <link href="${pageContext.request.contextPath}/static/plugins/jqGrid/css/custom.ui.jqgrid.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/layer/skin/layer.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/jqGrid/css/style.css" rel="stylesheet">

    <script src="${pageContext.request.contextPath}/static/js/jquery-1.11.3.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/common.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/jquery.form.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/jqGrid/js/i18n/grid.locale-cn.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/jqGrid/js/minified/jquery.jqGrid.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/layer/layer.js" type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/layer/extend/layer.ext.js"
            type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/static/js/jquery.form.js" type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/select2-4.0.0/dist/js/select2.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/global.js"></script>	
    <script src="${pageContext.request.contextPath}/static/js/placeholder.js"></script>
    <style type="text/css">
    .re{
    	width: 90%;
    	font-size: 25px;
    	margin-top: 15px;
    	margin: 0 auto;
    }
    .div1{
        margin: 0 auto;
    	width: 50%;
    	border: 1px solid #ccc;
    	border-radius: 0px 0px 20px 20px;
    }
    .div2{
        margin: 0 auto;
        padding: 10px 1px 5px 1px;
    	width: 50%;
    	border: 1px solid #ccc;
    	border-radius: 20px 20px 0px 0px;
    	margin-top: 5%;
    	
    }
    </style>	
</head>
<body>
<div class="">
    <div class="icon">
        <a class="icon-title">ZHANG
            LIAN</a>
    </div>
    <div class="top_left">
        <h5>
            <span>掌连，您的社区管家</span>
        </h5>
    </div>
</div>
<div class="div2">
		<div class="re"><span >申请互联网+管理账号</span></div>
</div>
<div class="div1">
    <form id="uploadForm" class="form-horizontal" style="padding-top: 10px">
    <div class="form-horizontal m-t">
    	 <input type="hidden" name="type" value="0">
    	<div class="form-group">
            <label class="col-sm-3  control-label"><i class="require">*</i>登录账号:</label>
            <div class="col-sm-8">
                <input class="form-control" name="adminUser" id="adminUser" placeholder="填写有效手机号，用于登录系统、找回密码" size="30"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3  control-label"><i class="require">*</i>登录密码:</label>
            <div class="col-sm-8">
                 <input class="form-control" type="password" name="comm" id="comm" placeholder="请输入密码，密码为6-16位，字母、数字或英文符号" size="30"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3  control-label"><i class="require">*</i>确认密码:</label>
            <div class="col-sm-8">
                 <input class="form-control" type="password" name="againPassword" id="againPassword" placeholder="请再次输入密码" size="30"/>
            </div>
        </div>
        <div class="form-group">
	        <label class="col-sm-3 control-label"><i class="require">*</i>联系人:</label>
	        <div class="col-sm-8">
	            <input class="form-control" name="agtContact" id="agtContact" placeholder="请填写联系人名称，中文或英文" size="30"/>
	        </div>
	    </div>
	    <div class="form-group">
	        <label class="col-sm-3 control-label"><i class="require">*</i>联系方式:</label>
	        <div class="col-sm-8">
	            <input class="form-control" name="agtTel" id="agtTel" placeholder="请填写联系人手机号" size="30"/>
	        </div>
	    </div>
         <div class="form-group">
            <label class="col-sm-3  control-label"><i class="require">*</i>公司名称:</label>
            <div class="col-sm-8">
                <input class="form-control" name="agtName" id="agtName" placeholder="请填写与与营业执照相同的公司名称" size="30"/>
            </div>
        </div>
        <div class="form-group">
	        <label class="col-sm-3 control-label"><i class="require">*</i>所属区域:</label>
	        <div class="col-sm-8" id="region">
	            <script type="text/javascript">
	                loadRegions();
	            </script>
	        </div>
    	</div>
       <div class="form-group">
            <label class="col-sm-3  control-label">地址:</label>
            <div class="col-sm-8">
                <input class="form-control" name="address" id="address" placeholder="填写公司通讯地址" size="30"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 col-sm-3 control-label">营业执照:</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input class="form-control" name="agtAttr"  id="agtAttr" readonly="readonly" size="30"/>
                    <div class="input-group-addon upload">
                        <input class="form-control" id="upload" type="file" name="upload"
                               style="position: absolute;width: 60px;opacity: 0;"/>
                        <a class="btn btn-primary">上传</a>
                    </div>
                </div>
            </div>
        </div>
         <div style="text-align: center;margin: 30px;">
             <input class="btn btn-success form-control"  type="button" onclick="cancle()"  style="width: 150px;margin-right: 70px;" value="取消">
             <input class="btn btn-success form-control"  type="button" id="sub" onclick="doUpload()"  style="width: 150px;" value="提交">
         </div>
    </div>
    </form>
</div>
<script>
function cancle(){
	window.location.href = "${pageContext.request.contextPath}/admin/zlindex.action?loginFlag=login";
}
function doUpload() {  
	$("#sub").attr("disabled", "true");
	var formData = new FormData($( "#uploadForm" )[0]); 
	var adminUser = $("#adminUser").val();
    var password = $("#comm").val();
    var againPassword = $("#againPassword").val();
    var agtName = $("#agtName").val();
    var agtContact = $("#agtContact").val();
    var agtTel = $("#agtTel").val();
    var selects=document.getElementsByName('areaCode');
    var areaCode = selects[0].value;
    var agtAttr = $("#agtAttr").val();

     
    if(!adminUser){
    	 alert("登录账号必填");
    	 $("#sub").removeAttr("disabled");
    	 return;
    }else if(!(/^1[3|4|5|7|8]\d{9}$/.test(adminUser))){ 
        alert("登录账号有误，请填写手机号格式"); 
        $("#sub").removeAttr("disabled");
        return; 
    }
    if(!password){
    	 alert("登录密码必填");
    	 $("#sub").removeAttr("disabled");
    	 return;
    }else if(!(/^[A-Za-z_0-9\x21-\x7e]{6,16}$/.test(password))){
    	 alert("登录密码有误，请填写6-16位，字母、数字或英文符号"); 
         $("#sub").removeAttr("disabled");
         return; 
    }
    if(!againPassword){
    	alert("确认密码必填");
   		$("#sub").removeAttr("disabled");
   	 	return;
    }else if(password != againPassword){
   	 	alert("确认密码和登录密码不匹配"); 
     	$("#sub").removeAttr("disabled");
     	return; 
	}
    if(!agtName){
    	 alert("公司名称必填");
    	 $("#sub").removeAttr("disabled");
    	 return;
    }
    if(!agtContact){
    	 alert("联系人姓名必填");
    	 $("#sub").removeAttr("disabled");
    	 return;
    }else if(!(/^[a-zA-Z\u4e00-\u9fa5]*$/.test(agtContact))){
   	 alert("联系人姓名有误，请填写中文或者英文"); 
     $("#sub").removeAttr("disabled");
     return; 
	}
    if(!agtTel){
    	 alert("联系方式必填");
    	 $("#sub").removeAttr("disabled");
    	 return;
    }else if(!(/^1[3|4|5|7|8]\d{9}$/.test(agtTel))){ 
        alert("联系方式有误，请填写手机号格式"); 
        $("#sub").removeAttr("disabled");
        return; 
    }
    
    if(!areaCode){
    	 alert("所属区域必填");
    	 $("#sub").removeAttr("disabled");
    	 return;
    }
    $.ajax({  
         url: '${pageContext.request.contextPath}/register/tagentAdd.action' ,  
         type: 'POST',  
         data: formData,  
         async: false,  
         cache: false,  
         contentType: false,  
         processData: false,  
         success: function (result) {  
              result = JSON.parse(result)
              if (result.code == 1) {
             	 layer.alert(result.msg);
             	 window.location.href = "${pageContext.request.contextPath}/admin/login.action";
              }else{
             	 $("#sub").removeAttr("disabled");
              	layer.alert(result.msg);
              }
         },  
         error: function (returndata) {  
             alert(returndata);  
         }  
    });  
} 
	function upload() {
        document.getElementById("upload").click();
    }
	 $("#upload").change(function () {
	        var filename = $(this).val();
	        var index = filename.lastIndexOf("\\");
	        $("input[name='agtAttr']").val(filename.substring(index + 1));
	  });
	
	
</script>
</body>
</html>
